package A1_二叉树;

import static java.lang.Math.max;

public class LC_104二叉树的最大深度 {
    public static class TreeNode{
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode(){}
        TreeNode(int val){
            this.val=val;
        }
        TreeNode(int val, TreeNode left, TreeNode right){
            this.val=val;
            this.left=left;
            this.right=right;
        }
    }
    public int maxDepth(TreeNode root) {
        if(root==null)
            return 0;
        int leftheight=maxDepth(root.left);
        int rightheight=maxDepth(root.right);
        int height=1+max(leftheight,rightheight);
        return height;
    }
}
